<?php
$base_columns = [
    [
        "field" => "user_name"
        , "type" => "varchar"
        , "rules" => "required|max:16"
        , "required" => 1
        , "description" => "用户姓名"
    ],
    [
        "field" => "mobile"
        , "type" => "varchar"
        , "rules" => "required|max:16"
        , "required" => 1
        , "description" => "mobile"
    ],
    [
        "field" => "salt"
        , "type" => "char"
        , "rules" => "required"
        , "required" => 1
        , "description" => "注册时随机10位数字"
    ],
    [
        "field" => "password"
        , "type" => "varchar"
        , "rules" => "required|max:64"
        , "required" => 1
        , "description" => "登录密码,md5(password)"
    ],
    [
        "field" => "status_id"
        , "type" => "tinyint"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "0=禁用,1=有效"
    ],
    [
        "field" => "gender"
        , "type" => "tinyint"
        , "rules" => "required|integer"
        , "required" => 1
        , "description" => "0=unknow,1=male,2=female"
    ],
    [
        "field" => "created_by"
        , "type" => "varchar"
        , "rules" => "max:32"
        , "required" => 0
        , "description" => "创建人"
    ],
];

return [
    "group" => "default",
    "controller" => "App\\Http\\Controllers\\AdminController",
    "description" => "admin 基本接口",
    "resource" => "admin",
    "methods" => [
        [
            "middleware" => ["oauth"],
            "method" => "manage",
            "requestMethod" => "POST",
            "requestRoute" => "/admin/grid",
            "description" => "管理 admin",
            "inputs" => [
                [
                    "field" => "page"
                    , "rules" => "numeric"
                    , "description" => "页码（第几页），默认为1"
                ],
                [
                    "field" => "page_size"
                    , "rules" => "numeric"
                    , "description" => "翻页大小，默认=10"
                ]
            ],
            "outputs" => $base_columns,
            "errors" => [
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "create",
            "requestMethod" => "POST",
            "requestRoute" => "/admin",
            "description" => "创建 admin",
            "inputs" => $base_columns,
            "outputs" => $base_columns,
            "errors" => [
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "detail",
            "requestMethod" => "POST",
            "requestRoute" => "/admin/{admin_id}",
            "description" => "获取 admin",
            "inputs" => [
            ],
            "outputs" => $base_columns,
            "errors" => [
                [
                    "code" => "record.not.found"
                    , "message" => "没有找到记录"
                ]
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "update",
            "requestMethod" => "POST",
            "requestRoute" => "/admin/{admin_id}",
            "description" => "修改 admin",
            "inputs" => $base_columns,
            "outputs" => $base_columns,
            "errors" => [
                [
                    "code" => "record.not.found"
                    , "message" => "没有找到记录"
                ]
            ]
        ],
        [
            "middleware" => ["oauth"],
            "method" => "remove",
            "requestMethod" => "DELETE",
            "requestRoute" => "/admin/{admin_id}",
            "description" => "删除 admin",
            "inputs" => [
            ],
            "outputs" => [
            ],
            "errors" => [
                [
                    "code" => "record.used"
                    , "message" => "记录已经被使用，存在重要数据，无法删除"
                ]
            ]
        ]
    ]
];